package com.medical.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root;
import javax.persistence.metamodel.SingularAttribute;

import org.springframework.beans.factory.InitializingBean;

public class DbOperation  {

	private EntityManagerFactory emf;
	private EntityManager entityManager;

	/**
	 * 
	 * @param entityManager
	 */
	@PersistenceContext(type = PersistenceContextType.EXTENDED)
	public void setEntityManager(final EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	public DbOperation() {
	}

	public boolean saveOrUpdate1(Object obj) {

	
		return true;

	}

	protected boolean delete(Object obj) {

			return true;
	}

	public List<Object> listAll(Class cls) {
	return new ArrayList<Object>();
	}

	public List<Object> list(Class cls, Map param) {
		return new ArrayList<Object>();
	}

	public List<Object> listByJpaQl(Class cls, Map param) {
		return new ArrayList<Object>();
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		// TODO Auto-generated method stub

	}

	protected EntityManager getEntityManager() {

		emf = Persistence.createEntityManagerFactory("DbOperation");
		entityManager = emf.createEntityManager();
		return entityManager;
		// return (Session) entityManager.getDelegate();
	}

}
